package com.ss.android.article.base.feature.model;

import android.content.Context;

import com.ss.android.common.ad.MobAdClickCombiner;
import com.ss.android.common.app.permission.PermissionsResultAction;
import com.ss.android.common.download.DownloadAdapterProxy;
import com.ss.android.common.download.DownloadInfoChangeListener;
import com.ss.android.newmedia.util.AppUtil;

import org.json.JSONObject;

final class d extends PermissionsResultAction {
    private final AppAd i;
    private final Context a;
    private final JSONObject b;
    private final DownloadInfoChangeListener c;
    private final int d;
    private final String e;
    private final JSONObject f;
    private final long g;
    private final String h;

    d(AppAd arg1, Context arg2, JSONObject arg3, DownloadInfoChangeListener arg4, int arg5, String arg6, JSONObject arg7, long arg8, String arg10) {
        this.i = arg1;
        this.a = arg2;
        this.b = arg3;
        this.c = arg4;
        this.d = arg5;
        this.e = arg6;
        this.f = arg7;
        this.g = arg8;
        this.h = arg10;

    }

    public final void onGranted() {
        long v10 = 0;
        long v2 = AppUtil.a(this.i.downloadUrl, this.i.appName, this.a, this.b);
        if(v2 < v10 || this.c == null) {
            if(v2 >= v10) {
                return;
            }
            MobAdClickCombiner.onAdEvent(this.a, this.e, "download_failed", this.i.id, v10, this.f, this.i.p);
        }
        else {
            android.support.design.a.a(new com.ss.android.article.base.feature.b.a(this.i.id, System.currentTimeMillis()), false);
            DownloadAdapterProxy.inst().registerDownloadListener(this.a, Long.valueOf(v2), this.c, String.valueOf(this.i.id), this.d, this.i.logExtra);
            MobAdClickCombiner.onAdEvent(this.a, this.e, "click_start", this.i.id, v10, this.f, this.i.p);
            if(this.g == 2 && this.d == 1) {
                MobAdClickCombiner.onAdEvent(this.a, this.h, "feeds_download", this.i.id, v10, this.f, 2);
            }

            if(android.support.design.a.isTextEmpty(this.i.alertText)) {
                return;
            }

            this.i.o = true;
        }
    }

    public final void onDenied(String arg1) {
    }
}

